package com.yunyao.web.controller;

import com.yunyao.common.dto.CheckMarkDtoDto;
import com.yunyao.common.dto.PrePaymentDto;
import com.yunyao.common.web.util.PageResult;
import com.yunyao.common.web.util.YResult;
import com.yunyao.dao.model.BamuPurchaseContractPrePayment;
import com.yunyao.dao.service.bamu.IBamuPurchaseContractPrePaymentService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

/**
 * 采购销售合同预收款
 */
@RestController
@RequestMapping("/contract/payment")
public class PurchaseContractPrePaymentController {


    @Resource
    private IBamuPurchaseContractPrePaymentService purchaseContractPrePaymentService;


    /**
     * 列表
     *
     * @param dto
     * @return
     */
    @PostMapping("/pageList")
    public YResult<PageResult<BamuPurchaseContractPrePayment>> pageList(@RequestBody @Valid @NotNull PrePaymentDto dto) {
        return YResult.success(purchaseContractPrePaymentService.pageList(dto));
    }


    @GetMapping("/findByIdInfo")
    public YResult<BamuPurchaseContractPrePayment> findByIdInfo(@NotBlank String id) {
        return YResult.success(purchaseContractPrePaymentService.findByIdInfo(id));
    }

    /**
     * 合同预收款收款完成
     *
     * @param dto
     * @return
     */
    @PostMapping("/finishPayment")
    public YResult<Void> finishPayment(@RequestBody @Valid @NotNull CheckMarkDtoDto dto) {
        purchaseContractPrePaymentService.finishPayment(dto);
        return YResult.success();
    }


}
